import React from 'react';
import {  useLocation, useNavigate } from '../react-router';

function Login(props) {
    let navigate = useNavigate()
    let location = useLocation()
    const login = ()=>{
        localStorage.setItem('login',true)
        let to= '/';
        if(location.state){
            to = location.state.from || '/'
        }
        navigate(to)
    }
    return (
        <button onClick={login}>
            Login 
        </button>
    );
}

export default Login;